package com.hjk.waibao.mj.controller;

import cn.hutool.core.util.StrUtil;
import com.hjk.waibao.mj.annotation.LoginUser;
import com.hjk.waibao.mj.common.model.User;
import com.jfinal.core.Controller;
import com.jfinal.kit.PropKit;

import java.io.UnsupportedEncodingException;
import java.util.regex.Pattern;

/**
 * 本 demo 仅表达最为粗浅的 jfinal 用法，更为有价值的实用的企业级用法
 * 详见 JFinal 俱乐部: http://jfinal.com/club
 * <p>
 * IndexController
 */
public class IndexController extends Controller {
    public static String adminId = PropKit.get("admin_id");
    public static final Pattern IMAGE_PATTERN = Pattern.compile("\\{\\{\\{([\\s\\S]+?)\\}\\}\\}");

    public void index(@LoginUser User user) throws UnsupportedEncodingException {
        if (StrUtil.equals(user.getId(), adminId)) {
            render("adminIndex.html");
        } else {
            renderText("自动化授权系统");
        }
    }

    public void loginAdmin() {
        render("login.html");
    }
}



